-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supavisor V2 #408
Open
abc3
wants to merge
98
commits into
main
Choose a base branch
from
v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Supavisor V2 #408
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reason for that is that `a || b` will expand to: ``` case a do val when val in [false, nil] -> b val -> val end ``` Which is harder to optimise by the compiler. `or/2` works only with booleans, so in places where we do not care about returned value or `nil` cases, it is better to use `or/2`.
* ft: improve socket metrics gathering As we are only interested in just 2 of the values from the socket stats, fetch only these. This should reduce time required for processing data sent between port and application. It also simplifies pattern matching and data extraction. * ft: gather metrics from other nodes with low priority
* chore: update Benchee * chore: unlock telemetry_metrics * chore: remove unused libraries from lockfile * chore: update Rustler and Rust dependencies * chore: update direct dependencies * chore: upddate Phoenix.LiveView
Supavisor is not using any HTML views, it do not offer any HTML-based UI, etc. so these functionalities aren't needed for anything.
I have used [`typos`][typos] tool to find all typos in source code over the codebase. [typos]: https://github.com/crate-ci/typos
* chore: add Nix Flake to project Currently it defines only development environment for Supavisor. In the future the plan is to add package definition as well as NixOS module to the Flake. This will simplify deployment on NixOS platforms as well as should help with spawning virtual machines with Supavisor running on them. * ft: add derivation for Supavisor
All changes required by our code are merged to mainline, so we do not need to use custom fork anymore.
feat: shorter retry connect timeout for proxy mode
This will raise if there are some pending changes to the `mix.lock`. This is to ensure, that `mix.lock` was uploaded after dependency changes.
* fix: update max clients error in session mode
That tests are constantly causing us problems in CI, but as it is test for internal functionality that do not affect users directly. So to streamline testing disable running these tests in default run. To run them one can use mix test --include flaky
These plugs weren't used at all, as we do not serve any static assets nor we need live reload for anything (as we do not have any form of web UI).
hauleth
approved these changes
Nov 16, 2024
Handle errors during authentication query gracefully and shutdown the client process to not leave the hanging connections.
* test: increase pool size in external test suite to match nano instances * test: make timeouts configurable * test: disable prepared transactions test, as these are disabled for security reasons * test: disable cursor tests in transaction mode * test: disable custom socket test * test: disable MAX_PARAMETERS_EXCEEDED test * test: disable query format errors test * test: run connection reserving test only in session mode * test: make Postgres.js more verbose * test: ensure connections with different parameters are available where needed * test: fix typo in test name
This allows us to use this piece of code in function head in pattern match. This reduces places where the magic value is required and make the code a little bit neater and cleaner.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR, Supavisor has been adapted for Erlang 27 and Elixir 1.17. The metrics backend has been changed from PromEx to Peep, and the most significant change is the introduction of ProxyHandler for processing transaction mode.
The ProxyHandler first authenticates the incoming connection through auth_query. If there is no connection pool, it creates one and also launches a Ranch on a free port, saving the port and host in the corresponding Syn record.
If the pool is on the same node as the client connection, we locally change the owner of the TCP socket for each transaction to the direct connection with the database. After the transaction is completed, the client process returns ownership of the TCP socket to the DbHandler.
If the pool is on a different node, the client process connects to the Ranch of the corresponding pool on the other node, switches to session mode, and forwards everything (works like proxy). The local Ranch operates the same way as when the client connection is on the same node as the connection pool.
With this handler, erldist is used only for synchronizing Syn. Forwarding query data between nodes is done via TCP sockets (Ranch)